local CreateView = class("CreateRoomView",function()
	return display.newNode()
end)

function CreateView:ctor(callback)
		self:setTouchEnabled(true)
		display.newColorLayer(cc.c4b(100,100,100,100)):addTo(self)
	    local width =display.width

	local listWidth = width-200*2

    cc.LayerColor:create(cc.c4b(100, 100, 100, 255),listWidth,display.height-100)
    :align(display.CENTER, 200, 50)
    :addTo(self)

		cc.ui.UIPushButton.new("Button01.png", {scale9 = true,size = 16})
        :setButtonSize(listWidth-100, 40)
        :setButtonLabel(cc.ui.UILabel.new({text = "创建房间"}))
        :onButtonPressed(function(event)
            event.target:setScale(1.1)
        end)
        :onButtonRelease(function(event)
            event.target:setScale(1.0)
        end)
        :onButtonClicked(function()
        	if self.nameET:getText() ~= "" then
            	callback(self.nameET:getText())
            end
        end)
        :pos(200+listWidth/2, display.height-160-60)
        :addTo(self)

        self.nameET = cc.ui.UIInput.new({
            image = "EditBoxBg.png",
            size = cc.size(listWidth-100, 50),
            x = 200+listWidth/2,
            y =  display.height-160,
            listener = function(event, editbox)
                -- if event == "changed" then
               --      self:onEditBoxChanged(editbox)
               --  else
               --      printf("EditBox event %s", tostring(event))
               --  end
            end
        })
        self.nameET:setPlaceHolder("请输入房间名")
        :setReturnType(cc.KEYBOARD_RETURNTYPE_SEND)
        self:addChild(self.nameET)

         cc.ui.UIPushButton.new("Button01.png", {scale9 = true})
        :setButtonSize(100, 40)
        :setButtonLabel(cc.ui.UILabel.new({text = "关闭"}))
        :onButtonPressed(function(event)
            event.target:setScale(1.1)
        end)
        :onButtonRelease(function(event)
            event.target:setScale(1.0)
        end)
        :onButtonClicked(function()
            self:removeSelf()
        end)
        :pos(display.width-250, display.height-100/2-20)
        :addTo(self)
end

return CreateView